﻿using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using SECSDevice.Model;

namespace SECSDevice.Handler
{
    internal class ParseTextToSF
    {
        public ParseTextToSF() { }
        public ParseTextToSF(string text) { }

        public static List<SFModel> ParseToSF()
        {
            Regex regex = new Regex(@"((S[0-9]+F[0-9]+){1})");
            List<SFModel> listSFModel = new List<SFModel>();
            try
            {

                using (StreamReader sr = new StreamReader(Constants.Gem_File_Path, Encoding.UTF8))
                {
                    string line = sr.ReadToEnd();

                    string[] strings = line.Split(new char[] { '.' });

                    foreach (string item in strings)
                    {
                        if (regex.IsMatch(item))
                        {
                            string[] values = item.Split(new char[] { ':' });

                            listSFModel.Add(new SFModel() { Name = values[0].TrimStart('\r', '\n'), Type = new Regex(@"(S[0-9]+){1}").Match(item).Value, Content = values[1].TrimStart('\r', '\n') + "." });
                        }
                    }
                }
            }
            catch
            {

            }
            return listSFModel;
        }
    }
}
